package com.midian.model.organization;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.midian.common.utils.StringUtil;
import com.midian.model.common.BaseModel;
import com.midian.model.pic.Pic;


/**
 * 机构
 * 
 */
@Entity
@Table(name = "organization")
public class Organization extends BaseModel {
	/**机构名称*/
	private String name;
	/**联系人姓名*/
	private String contactPerson;
	/**联系人号码*/
	private String contactNum;
	/**联系地址*/
	private String contactAddress;
	/**机构logo图片对象*/
	@ManyToOne(optional=true,fetch=FetchType.LAZY)
	@JoinColumn(name="logo")
	@NotFound(action=NotFoundAction.IGNORE)
	private Pic logo;
	/**机构类型名*/
	@ManyToOne(optional=true,fetch=FetchType.LAZY)
	@JoinColumn(name="type_id")
	@NotFound(action=NotFoundAction.IGNORE)
	private OrganizationType orgType;
	
	
	public Pic getLogo() {
		return logo;
	}

	public void setLogo(Pic logo) {
		this.logo = logo;
	}

	public OrganizationType getOrgType() {
		return orgType;
	}

	public void setOrgType(OrganizationType orgType) {
		this.orgType = orgType;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getContactPerson() {
		return contactPerson;
	}

	public void setContactPerson(String contactPerson) {
		this.contactPerson = contactPerson;
	}

	public String getContactNum() {
		return contactNum;
	}

	public void setContactNum(String contactNum) {
		this.contactNum = contactNum;
	}

	public String getContactAddress() {
		return contactAddress;
	}

	public void setContactAddress(String contactAddress) {
		this.contactAddress = contactAddress;
	}
	
	/**logo地址*/
	@Transient
	public String getLogoIp() {
		String logoIp="";
		if (this.logo!=null) {
			logoIp = StringUtil.getImageTips(this.logo.getId());
		}
		return logoIp;
		
	}
	
	
}
